package homework.homework02;

import java.lang.reflect.Constructor;
import java.util.Properties;

public class HomeWork01 {
    public static void main(String args[]){
        Properties p = new Properties();
        try {
            p.load(HomeWork01.class.getClassLoader()
                    .getResourceAsStream("homework/homework02/student.properties"));
            Class<?> aClass = Class.forName("homework.homework02.StudentBean");
           Constructor c =  aClass.getDeclaredConstructor(String.class, String.class, int.class);
           String name = p.getProperty("name");
           name = new String(name.getBytes("iso8859-1"),"utf-8");
           String gender = p.getProperty("gender");
            gender = new String(gender.getBytes("iso8859-1"),"utf-8");
            StudentBean s = (StudentBean) c.newInstance(
                    name,
                    gender,
                    Integer.parseInt(p.getProperty("age")));

            System.out.println(s.getAge() + "   "+ s.getGender() + "     " + s.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
